package com.sl.service;

import com.sl.mapper.RoleRouteMapper;
import com.sl.pojo.RoleRoute;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleRouteService {

    @Resource
    private RoleRouteMapper roleRouteMapper;

    //查询：所有
    public List<RoleRoute> findAll(){
        List<RoleRoute> roleRoutes = roleRouteMapper.selectAll();
        return  roleRoutes;
    }
    //查询：主键
    public RoleRoute findById(Integer id){
        return  roleRouteMapper.selectByPrimaryKey(id);
    }
    //查询：roleId查权限
    public List<RoleRoute> findByRoleId(Integer roleId){
        Example example = new Example(RoleRoute.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("roleId",roleId);
        List<RoleRoute> roleRoutes = roleRouteMapper.selectByExample(example);
        return roleRoutes;
    }
    //增加
    public void add(RoleRoute roleRoute){
        roleRouteMapper.insertSelective(roleRoute);
    }
    //x修改
    public void update(RoleRoute roleRoute){
        roleRouteMapper.updateByPrimaryKeySelective(roleRoute);
    }
    public void delete(RoleRoute roleRoute){
        roleRouteMapper.deleteByPrimaryKey(roleRoute);
    }
}
